﻿@*
    For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
*@
@{
    Layout = "_Layout";
}
<body class="layui-anim layui-anim-up">
    <div class="x-nav">
        <span class="layui-breadcrumb">
            <a href="/Admin/Admin/Index">首页</a>
            <a>
                <cite>订单列表</cite>
            </a>
        </span>
        <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">
            <i class="layui-icon" style="line-height:30px">ဂ</i>
        </a>
    </div>
    <div class="x-body">
        <xblock>
            <div class="layui-inline">
                <input type="text" placeholder="请输入订单号或作品名称" autocomplete="off" class="layui-input search_input">

            </div>
            <button class="layui-btn search_btn" lay-filter="sreach"><i class="layui-icon">&#xe615;</i></button>
        </xblock>
        <table class="layui-table" lay-data="{ url:'/Admin/Order/GetOrder', page:true, id:'order'}" lay-filter="order">
            <thead>
                <tr>
                    <th lay-data="{field:'', width:'5%', sort: true,type:'numbers'}">ID</th>
                    <th lay-data="{field:'OrderId', width:'15%'}">订单号</th>
                    <th lay-data="{field:'Price', width:'8%'}">价格</th>
                    <th lay-data="{field:'PayType' , width:'15%', templet: '#paytype'}">支付类型</th>
                    <th lay-data="{field:'WorkTitle', width:'20%'}">作品名称</th>
                    <th lay-data="{field:'UserName', width:'15%'}">用户名</th>
                    <th lay-data="{field:'Num', width:'7%'}">数量</th>
                    <th lay-data="{field:'State', width:'20%'，, templet: '#state'}">状态</th>
                    <th lay-data="{field:'' , width:'15%' , templet: '#barDemo'}">操作</th>
                </tr>
            </thead>
        </table>

        <script type="text/html" id="state">
            {{#  if(d.State==0){ }}
            <span>待支付</span>
            {{#  }else if(d.State==1){ }}
            <span>已支付</span>
            {{#  }else{ }}
            <span>未知</span>
            {{#  } }}
        </script>

        <script type="text/html" id="paytype">
            {{#  if(d.State==0){ }}
            <span>微信支付</span>
            {{#  }else{ }}
            <span>支付宝</span>
            {{#  } }}
        </script>

        <script type="text/html" id="barDemo">
            <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
        </script>

    </div>
    <script>
layui.use(['laydate', 'table', 'form','layer'], function () {
            var laydate = layui.laydate;
            var table = layui.table;
            var $ = layui.jquery;
            var form = layui.form;
            var layer=layui.layer;

            //监听行工具事件
            table.on('tool(order)', function (obj) {
                var data = obj.data;
                //console.log(obj)
                if (obj.event === 'del') {
                    layer.confirm('真的删除行么', function (index) {

                        $.ajax({
                            type: "post",
                            url: "/Admin/Order/Del",
                            data: { orderId: data.OrderId},
                            success: function (result) {
                                if (result.state == "ok") {
                                    layer.msg(result.msg)
                                } else {
                                    layer.msg(result.msg)
                                }
                            }
                        })

                        obj.del();

                    });
                } else if (obj.event === 'tg') {
                   $.ajax({
                    type: "post",
                    url: "/Admin/Apply/UpState",
                    data: { id: data.Id ,userid:data.UserId,state:1},
                    success: function (result) {
                        if (result.state == "ok") {
                            layer.msg(result.msg)
                        } else {
                            layer.msg(result.msg)
                        }
                    }
                   })
                }
            });

                var active = {
                reload: function() {
                    //执行重载
                    table.reload('order', {
                        page: {
                            curr: 1
                        },
                        where: {
                            content: $.trim($(".search_input").val())
                        }
                    });
                }
            };
            $('.search_input').bind('keyup', function(event) {
                if (event.keyCode == "13") {
                    var type = 'reload';
                    active[type] ? active[type].call(this) : '';
                }
            });
            //查找
            $(".search_btn").click(function() {
                var type = 'reload';
                active[type] ? active[type].call(this) : '';
            });
        });</script>
</body>

